/*
ID: icerupt1
PROG: telecow
LANG: C++11
*/

/* solution
 *
 * great.网络流字典序最小最小割。
 * 和4.4的一题一模一样，不过试标号法没成功。。
 *
 * http://wjmzbmr.com/archives/usaco_telecowmunication/
 *
*/
#include <fstream>
#include <iostream>
#include <limits>
#include <queue>

std::ifstream fin {"telecow.in" };
std::ofstream fout{"telecow.out"};

template <class T>
struct dinic
{
	using value_type = T;
	using size_type = int;

	struct edge {
		size_type from, to;
		value_type capacity, flow;
	};

	dinic(size_type num) : size(num)
	{
		graph.resize(num);	//[0, num)
		dist.resize(num);	//[0, num)
	}

	void add_edge(int u, int v, value_type cap)
	{
		edge tmp;
		tmp.from = u; tmp.to = v; tmp.capacity = cap; tmp.flow = 0;
		edges.push_back(tmp);
		graph[u].push_back(edges.size() - 1);

		tmp.from = v; tmp.to = u; tmp.capacity = 0; tmp.flow = 0;
		edges.push_back(tmp);
		graph[v].push_back(edges.size() - 1);
	}

	auto bfs_label(size_type source, size_type target)
	{
		std::fill(dist.begin(), dist.end(), -1);
		std::queue<size_type> q;
		q.push(source);
		dist[source] = 0;
		while (!q.empty()) {
			auto now = q.front();
			q.pop();
			for (auto it = graph[now].begin(); it != graph[now].end(); ++it) {
				edge e = edges[*it];
				if (dist[e.to] == -1 && e.capacity > e.flow) {
					q.push(e.to);
					dist[e.to] = dist[now] + 1;
				}
			}
		}
		return dist[target] != -1;
	}

	auto dfs(size_type v, size_type target, value_type f)
	{
		if (v == target || !f) return f;
		value_type block_flow = 0;
		for (auto it = graph[v].begin(); it != graph[v].end(); ++it) {
			edge & e = edges[*it];
			if (e.capacity > e.flow && dist[e.to] == dist[v] + 1) {
				value_type tmp = dfs(e.to, target,
						std::min(e.capacity - e.flow, f - block_flow));
				block_flow += tmp;
				e.flow += tmp;
				edges[(*it) ^ 1].flow -= tmp;
			}
		}
		if (!block_flow) dist[v] = -1;
		return block_flow;
	}

	auto max_flow(size_type source, size_type target)
	{
		value_type flow = 0;
		for (int tmp; bfs_label(source, target); )
			while ((tmp = dfs(source, target, capacity_inf))) flow += tmp;
		return flow;
	}

	void clear_flow()
	{
		for (auto e = edges.begin(); e != edges.end(); ++e)
			(*e).flow = 0;
	}

//private:
	value_type const capacity_inf = std::numeric_limits<value_type>::max();
	size_type size;
	std::vector<int> dist;
	std::vector<edge> edges;
	std::vector<std::vector<size_type>> graph;
};

int main()
{
	int n, m, s, t;
	fin >> n >> m >> s >> t;
	s--; t--;
	dinic<int> d(2*n);
	for (int i = 0; i < n; i++) {
		int c = 1;
		if (i == s || i == t) c = d.capacity_inf;
		d.add_edge(2*i, 2*i + 1, c);
	}

	s = 2*s; t = 2*t + 1;
	for (int i = 0, x, y; i < m; i++) {
		fin >> x >> y;
		x--; y--;
		d.add_edge(2*x + 1, 2*y, d.capacity_inf);
		d.add_edge(2*y + 1, 2*x, d.capacity_inf);
	}

	int max_flow = d.max_flow(s, t);
	std::cout << max_flow << '\n';
	fout << max_flow << '\n';

	std::vector<int> list;
	for (auto i = 0u; max_flow && i < d.edges.size(); i += 2) {
		if (d.edges[i].capacity == 1)
			if (d.edges[i].flow == d.edges[i].capacity) {
				int tc = d.edges[i].capacity;
				d.edges[i].capacity = 0;
				d.clear_flow();
				if (d.max_flow(s, t) == max_flow - 1) {
					max_flow--;
					tc = 0;
					list.push_back(int(d.edges[i].from/2) + 1);
				} else
				d.edges[i].capacity = tc;
			}
	}

	std::cout << list[0];
	fout << list[0];
	for (int i = 1; i < (int)list.size(); i++) {
		std::cout << ' ' << list[i];
		fout << ' ' << list[i];
	}
	std::cout << '\n';
	fout << '\n';
}

